package com.gin.no_gay_alliance.viewmodel.notice;

import android.os.Parcel;
import android.os.Parcelable;

import com.gin.nga.response.field.notice.MessageNotice;

/**
 * 私信提醒
 *
 * @author : ginstone
 * @version : v1.0.0
 * @since : 2023/9/11 10:38
 **/
public class MessageNoticeModel extends BaseNoticeModel<MessageNotice> implements Parcelable {
    public static final Creator<MessageNoticeModel> CREATOR = new Creator<MessageNoticeModel>() {
        @Override
        public MessageNoticeModel createFromParcel(Parcel in) {
            return new MessageNoticeModel(in);
        }

        @Override
        public MessageNoticeModel[] newArray(int size) {
            return new MessageNoticeModel[size];
        }
    };
    /**
     * 消息id
     */
    public Long messageId;
    public boolean fromSystem;

    public MessageNoticeModel() {
    }

    public MessageNoticeModel(MessageNotice messageNotice) {
        super(messageNotice);

        this.messageId = messageNotice.getMessageId();
        this.fromSystem = messageNotice.getAuthorId() == 0;
    }

    protected MessageNoticeModel(Parcel in) {
        super(in);
        if (in.readByte() == 0) {
            messageId = null;
        } else {
            messageId = in.readLong();
        }
        fromSystem = in.readByte() != 0;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        if (messageId == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeLong(messageId);
        }
        dest.writeByte((byte) (fromSystem ? 1 : 0));
    }
}
